<?php
$this->render('include/sortLink.phtml');
$this->headScript()->appendFile(_STATIC_HTTP . '/jquery/checkAll.js');
if(!function_exists('__sortLink')) {
	function __sortLink() {}
}
?>
<table class="list">
	<tr>
		<th class="id"><?php echo __sortLink('id', '#', array('id' => $this->row->getId()));?></th>
		<th class="narrow sort"><?php echo __sortLink('name', 'KEY', array('id' => $this->row->getId()));?></th>
		<th><?php echo $this->language('INFORMATION');?></th>
		<th class="narrow sort" title="<?php echo $this->language('Photo Total Count');?>"><?php echo __sortLink('photo', 'PHOTO', array('id' => $this->row->getId()));?></th>
		<th class="time sort"><?php echo __sortLink('creationtime', 'CREATION', array('id' => $this->row->getId()));?></th>
		<th class="time sort"><?php echo __sortLink('date', 'MODIFIED', array('id' => $this->row->getId()));?></th>
		<th class="narrow center"><?php echo '<input type="checkbox" name="select-all" id="select-all" value="1" rel="id[]" />';?></th>
	</tr>
	<?php
	foreach($this->list AS $key => $row) {
		$categories = isset($this->categories[$row->getId()]) ? $this->categories[$row->getId()] : array();
		$keywords = isset($this->keywords[$row->getId()]) ? $this->keywords[$row->getId()] : array();
	?>
	<tr>
		<td class="icon"><a href="<?php echo $row->getCover()->getLarge(false);?>" target="_blank"><img src="<?php echo $row->getCover()->getThumb(false);?>" /></a></td>
		<td class="key center">
			<h3 style="font-family:Georgia;padding:3px;border:1px dashed #333;"><?php echo $row->getDisplayOrder();?></h3>
			<strong style="display:block;padding:4px 0;"><?php echo $row->getName();?></strong>
		</td>
		<td<?php if(!$row->getIsActive()) {echo ' class="gray"';}?>>
			<h3 class="title"><a href="<?php echo $this->url('picture/special/edit', array('id' => $row->getId()));?>"><?php echo $this->escape($row->getTitle());?></a></h3>
			<p class="tags">
				<span>[<?php echo $this->language('TAG');?>]: </span><?php
				$cs = array(); 
				foreach($keywords AS $kw) {
					$cs[] = '<a href="' . $this->url('resource/keyword/edit', array('id' => $kw['keyword_id'])) . '">' . $this->escape($kw['name']) . '</a>';
				}
				echo '<span>' . implode($cs, '; ') . '</span>';
				?>
			</p>
			<p class="tags">
				<span>[<?php echo $this->language('CATEGORY');?>]: </span><span><?php
				$cs = array(); 
				foreach($categories AS $category) {
					$cs[] = '<a href="' . $this->url('picture/category/edit', array('id' => $category['category_id'])) . '">' . $this->escape($category['title']) . '</a>';
				}
				echo implode($cs, ', ');
				?></span>
			</p>
			<p class="toolbar">
				<a href="<?php echo $this->url('picture/special/edit', array('id' => $row->getId()));?>"><?php echo $this->language('Edit');?>»</a>
				<a href="<?php echo $this->url('picture/special/photo', array('id' => $row->getId()));?>"><?php echo $this->language('Photos');?>(<?php echo $row->getPtotal();?>)»</a>
				<a href="<?php echo $this->url('picture/photo/batch', array('special_id' => $row->getId()));?>" class="batch"><?php echo $this->language('Upload');?>»</a>
				<a href="<?php echo $this->url('picture/special/delete', array('id' => $row->getId()));?>"><?php echo $this->language('Destroy');?>»</a>
			</p>
		</td>
		<td class="center<?php if(!$row->getPtotal()) echo ' gray';?>"><h1><a href="<?php echo $this->url('picture/special/photo', array('id' => $row->getId()));?>"><?php echo $row->getPtotal();?></a></h1></td>
		<td class="time"><?php echo $this->date($row->getCreationtime());?></td>
		<td class="time"><?php echo $this->date($row->getLastmodified());?></td>
		<td class="center"><?php
		if(in_array($row->getId(), $this->checkedList)) {
			$checked = array('checked' => 'checked');
		} else {
			$checked = array();
		}
		echo $this->form()->checkbox('id[]', $row->getId(), array_merge(array('id' => 'id-' . $row->getId()), $checked));
		?></td>
	</tr>
	<?php } ?>
	<?php if(count($this->list) <= 0) {?>
	<tr>
		<td colspan="7" class="nohover">
			<div class="msg">
				<div class="common error" style="border:0;background:#fff;">
					<i class="icon"></i>
					<h4>STOP</h4>
					<div class="msg-bd">
						No Special found. 
					</div>
				</div>
			</div>
		</td>
	</tr>
	<?php } ?>
</table>